﻿using Grow.Log.CreateLog;
using Grow.Log.Serilog.Seq.CreateLog;
using Grow.Log.Serilog.Seq.Logging;
using Grow.Module;
using Grow.Module.Service;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Grow.Log.Serilog.Seq
{
    public abstract class LogSeqModuleBase : ModuleBase, ILogModule
    {
        public override ModuleLevel Level => ModuleLevel.Framework;
        public override void AddDependModule(IDependModuleBuilder dependModuleBuilder)
        {
        }

        public override void AddService(IServiceContainer serviceContainer)
        {

            CreateLogBuilder createLogBuilder = new(serviceContainer);
            CreateLog(createLogBuilder);
            serviceContainer.BuilderManager.SetBuilder<ICreateLogBuilder>(createLogBuilder);


            _ = serviceContainer.ServiceCollection.AddTransient(typeof(ILog<>), typeof(Log<>));
            _ = serviceContainer.ServiceCollection.AddSingleton<ILoggerProvider, LoggerProvider>();
        }

        public abstract void CreateLog(ICreateLogBuilder createLogBuilder);

        public override void UseService(IServiceContext serviceContext)
        {
        }
    }
}
